<template>
  <div class="my-index">
    <!-- 导航栏 -->
    <van-nav-bar title="主页" fixed/>
    <!-- 搜索框 -->
    <van-search placeholder="输入关键词搜索"  style="margin-top: 56px"/>
    <!-- 下拉刷新 -->
    <van-pull-refresh
      v-model="isLoading"
      @refresh="onRefresh"
      success-text="刷新成功">
      <!-- 轮播图 -->
      <van-swipe :autoplay="2000">
        <van-swipe-item
          v-for="(img, index) in images"
          :key="index"
          height="56vw"
          ><img v-lazy="img" />
        </van-swipe-item>
      </van-swipe>
      <!-- 首页景点卡片 -->
      <div class="scenic_card">
        <!-- 卡片标题 -->
        <div class="card_title">
          <div>
            <span></span>
            <span>热门精选</span>
          </div>
          <span>更多</span>
        </div>
        <!-- 卡片内容 -->
        <div class="card_content">
          <div class="card">
            <img src="/cs-img/1-1.jpg" alt="" />
            <div>你好!魏根儿!</div>
            <p>今天的午饭有点粗糙, 整点辣根儿再配点小腰儿</p>
          </div>
          <div class="card">
            <img src="/cs-img/1-2.jpg" alt="" />
            <div>你好!社会尧儿!</div>
            <p>今天的午饭有点科技, 麻辣烫味道它有点问题</p>
          </div>
        </div>
        <!-- 卡片标题 -->
        <div class="card_title">
          <div>
            <span></span>
            <span>自由行</span>
          </div>
          <span>更多</span>
        </div>
        <!-- 卡片内容 -->
        <div class="card_content">
          <div class="card">
            <img src="/cs-img/1-3.jpg" alt="" />
            <div>你好! 阿俊儿!</div>
            <p>今天的嘴唇有点肿胀, 原来是春饼加了点京酱</p>
          </div>
          <div class="card">
            <img src="/cs-img/1-4.jpg" alt="" />
            <div>你好! 刘昕geigei!</div>
            <p>今天的棋局局势不好, 升级喽配上快速思考!</p>
          </div>
        </div>
      </div>
      <!-- 摄影作品 -->
      <div class="shoot_photo">
        <div class="shoot_title">
          <div>
            <span></span>
            <span>摄影作品</span>
          </div>
          <span>更多</span>
        </div>
        <div class="shoot_pic">
          <div class="pic">
            <div class="pic_name">高山</div>
            <img src="/cs-img/2-1.jpg" alt="">
          </div>
          <div class="pic">
            <div class="pic_name">美女</div>
            <img src="/cs-img/2-2.jpg" alt="">
          </div>
          <div class="pic">
            <div class="pic_name">雪屋</div>
            <img src="/cs-img/2-3.jpg" alt="">
          </div>
          <div class="pic">
            <div class="pic_name">草原</div>
            <img src="/cs-img/2-4.jpg" alt="">
          </div>
        </div>
      </div>
    </van-pull-refresh>
  </div>
</template>

<script>
export default {
  data() {
    return {
      // 轮播图 图片存放
      images: [
        "/cs-img/1.jpg",
        "/cs-img/2.jpg",
        "/cs-img/5.jpg",
        "/cs-img/6.jpg",
      ],
      // 下拉刷新
      isLoading: false,
    };
  },
  methods: {
    onRefresh() {
      setTimeout(() => {
        this.isLoading = false;
      }, 1000);
    },
  },
};
</script>
<style lang="scss" scoped>
// 轮播图样式修改
.van-swipe {
  margin: 10px 12px 0;
  overflow: hidden;
  border-radius: 5px;
  height: 56vw;

  img {
    display: block;
    width: 100%;
  }

  ::v-deep .van-swipe__indicator {
    width: 12px;
    height: 12px;
  }

  ::v-deep .van-swipe__indicator--active {
    background-color: #fdc03a;
  }
}
::v-deep.van-swipe__track {
  height: 56vw;
}
// 景点卡片标题样式
.scenic_card {
  margin: 25px 12px 0;
}
.card_title,.shoot_title {
  height: 30px;
  line-height: 30px;
  display: flex;
  justify-content: space-between;
  margin-bottom: 15px;
  border-bottom: 1px solid #fdc03a;
  margin-top: 25px;
  > div {
    display: inline-block;
  }
  > span {
    font-size: 12px;
  }
}
.card_title > div > span:nth-child(1),.shoot_title > div > span:nth-child(1) {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 100%;
  background-color: #f59922;
  margin-right: 8px;
}

.card_title > div > span:nth-child(2),.shoot_title > div > span:nth-child(2) {
  color: black;
  font-size: 20px;
  font-weight: bold;
}
// 景点卡片样式
.card_content {
  width: 100%;
  display: flex;
  justify-content: space-between;
}
.card {
  width: 48%;
  overflow: hidden;
  border-radius: 3px;
  > img {
    width: 100%;
    height: 60%;
  }
  > div {
    color: black;
    font-size: 18px;
    margin: 8px 0;
  }
  > p {
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }
}
// 摄影作品样式
.shoot_photo {
  margin: 0 12px;
  >.shoot_pic {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    >.pic {
      position: relative;
      width: 48%;
      margin-bottom: 13px;
      overflow: hidden;
      border-radius: 3px;
      >img {
        display: block;
        width: 100%;
      }
      >div {
        position: absolute;
        top: 10px;
        left: 10px;
        font-size: 20px;
        color: #fff;
        font-weight: 900;
      }
    }
  }
}
</style>
